/* GUI CONVERTED from reoprp22.p (converter v1.75) Sat Aug 12 23:06:58 2000 */
/* reoprp22.p - WORK CENTER / MACHINE PRODUCTIVITY REPORT               */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* web convert reoprp22.p (converter v1.00) Wed Sep 17 11:06:19 1997 */
/* web tag in reoprp22.p (converter v1.00) Mon Jul 14 17:24:47 1997 */
/*F0PN*/ /*K0ZB*/ /*                                                     */
/*V8:ConvertMode=FullGUIReport                                 */
/* REVISION: 1.0      LAST MODIFIED: 02/03/87   BY: EMB *A9* */
/* REVISION: 2.0      LAST MODIFIED: 05/19/87   BY: EMB      */
/* REVISION: 2.0      LAST MODIFIED: 07/23/87   BY: EMB      */
/* REVISION: 2.0      LAST MODIFIED: 08/31/87   BY: EMB      */
/* REVISION: 2.0      LAST MODIFIED: 04/12/88   BY: EMB      */
/* REVISION: 2.0      LAST MODIFIED: 04/20/88   BY: EMB      */
/* REVISION: 4.0      LAST MODIFIED: 02/03/88   BY: RL  *A171**/
/* REVISION: 4.0      LAST MODIFIED: 02/24/88   BY: WUG *A175**/
/* REVISION: 5.0      LAST MODIFIED: 03/27/89   BY: EMB      */
/* REVISION: 7.3      LAST MODIFIED: 04/27/93   BY: DZS *GA37**/
/* REVISION: 7.4      LAST MODIFIED: 01/12/94   BY: qzl *H276*/
/* REVISION: 7.4      LAST MODIFIED: 12/06/94   BY: cpp *FU18*/
/* REVISION: 7.3      LAST MODIFIED: 03/14/95   By: DZN *G0G8*     */
/* REVISION: 8.6      LAST MODIFIED: 10/14/97   BY: bvm *K0ZB*/

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan    */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 05/04/00   BY: *N09M* Inna Lyubarsky */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb              */
/*G0G8*/ /*V8:DontRefreshTitle=b */

/*K0ZB*/ /* DISPLAY TITLE */

/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

/*K0ZB*/ {mfdtitle.i "b+ "} /*H276*/

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE reoprp22_p_1 "Std Hrs"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp22_p_3 "Tot Hrs"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp22_p_4 "Report Format"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp22_p_5 "Std Rate"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp22_p_7 "Std Run"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp22_p_8 "Util %"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp22_p_11 "Down Hrs"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp22_p_12 "Prod Hrs"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp22_p_13 "Act Rate"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp22_p_14 "Detail/Summary"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp22_p_15 "Prod %"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp22_p_16 "Attain %"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp22_p_17 "Pcs Comp"
/* MaxLen: Comment: */

/*N09M --- DELETED TRANSLATABLE STRINGS DEFINITIONS -------- *
* &SCOPED-DEFINE reoprp22_p_2 "Report Total:"
* /* MaxLen: Comment: */
*
* &SCOPED-DEFINE reoprp22_p_6 "Shift:"
* /* MaxLen: Comment: */
*
* &SCOPED-DEFINE reoprp22_p_9 "Work Center / Machine Total:"
* /* MaxLen: Comment: */
*
* &SCOPED-DEFINE reoprp22_p_10 "Work Center: "
* /* MaxLen: Comment: */
*
* &SCOPED-DEFINE reoprp22_p_18 " Machine: "
* /* MaxLen: Comment: */
*N09M ------------------------------------------------------ */

/* ********** End Translatable Strings Definitions ********* */

define variable emp like op_emp.
define variable emp1 like op_emp.
define variable part like op_part.
define variable part1 like op_part.
define variable opdate like op_date.
define variable opdate1 like op_date.
define variable wkctr like op_wkctr.
define variable wkctr1 like op_wkctr.
define variable mach like op_mch.
define variable mach1 like op_mch.
define variable run_var like wr_run format "->>9.999".
define variable setup_var like wr_setup format "->>9.999".
define variable run_eff like wr_run format ">>>9.99%".
define variable setup_eff like run_eff.
define variable desc1 like pt_desc1.
define variable std_run like wr_run label {&reoprp22_p_7}.
define variable setup_per like wr_setup.
define variable tot_hours as decimal format "->,>>9.9" label {&reoprp22_p_3}.
define variable std_hours like tot_hours label {&reoprp22_p_1}.
define variable prod_hours like tot_hours label {&reoprp22_p_12}.
define variable down_hours like tot_hours label {&reoprp22_p_11}.
define variable achvd_rate as integer label {&reoprp22_p_13} format "->>>,>>9".
define variable pcs_comp like achvd_rate label {&reoprp22_p_17}.
define variable std_rate like achvd_rate label {&reoprp22_p_5}.
define variable shift like op_shift.
define variable detail like mfc_logical label {&reoprp22_p_4} initial yes
format {&reoprp22_p_14}.

/*N09M* ---- ADDED DEFINE VARIABLES ------------------------ */
define variable std_hrs_st        as decimal no-undo.
define variable down_hrs_st       as decimal no-undo.
define variable prod_hrs_st       as decimal no-undo.
define variable prod_pct_st       as decimal no-undo.
define variable util_pct_st       as decimal no-undo.
define variable attain_pct_st     as decimal no-undo.
define variable wc_mt             as character format "x(36)" no-undo.
/*N09M* ---------------------------------------------------- */

/*N09M* ---- ADD INITIAL VALUES ---------------------------- */
wc_mt = getTermLabel("WORK_CENTER",15) + " / " +
    getTermLabel("MACHINE_TOTAL",17) + ":".
/*N09M* ---------------------------------------------------- */

/*K0ZB* * moved up*
 * /* DISPLAY TITLE */
 * {mfdtitle.i "b+ "} /*H276*/
 *K0ZB*/


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
wkctr     colon 15      wkctr1    label {t001.i} colon 49
   mach      colon 15      mach1     label {t001.i} colon 49
   opdate    colon 15      opdate1   label {t001.i} colon 49
   part      colon 15      part1     label {t001.i} colon 49
   emp       colon 15      emp1      label {t001.i} colon 49
   shift     colon 15 skip (1)
   detail    colon 15
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

/*K0ZB*/ {wbrp01.i}


/*GUI*/ {mfguirpa.i true  "printer" 132 }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:


   if emp1 = hi_char then emp1 = "".
   if opdate = low_date then opdate = ?.
   if opdate1 = hi_date then opdate1 = ?.
   if part1 = hi_char then part1 = "".
   if wkctr1 = hi_char then wkctr1 = "".
   if mach1 = hi_char then mach1 = "".

/*K0ZB*/ if c-application-mode <> 'web' then
   
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


/*K0ZB*/ {wbrp06.i &command = update &fields = " wkctr wkctr1 mach mach1
          opdate opdate1 part part1 emp emp1 shift detail " &frm = "a"}

/*K0ZB*/ if (c-application-mode <> 'web') or
/*K0ZB*/ (c-application-mode = 'web' and
/*K0ZB*/ (c-web-request begins 'data')) then do:

   if emp1 = "" then emp1 = hi_char.
   if opdate = ? then opdate = low_date.
   if opdate1 = ? then opdate1 = hi_date.
   if part1 = "" then part1 = hi_char.
   if wkctr1 = "" then wkctr1 = hi_char.
   if mach1 = "" then mach1 = hi_char.

   bcdparm = "".
   {mfquoter.i wkctr  }
   {mfquoter.i wkctr1 }
   {mfquoter.i mach   }
   {mfquoter.i mach1  }
   {mfquoter.i opdate }
   {mfquoter.i opdate1}
   {mfquoter.i part   }
   {mfquoter.i part1  }
   {mfquoter.i emp    }
   {mfquoter.i emp1   }
   {mfquoter.i shift  }
   {mfquoter.i detail }

/*K0ZB*/ end.

   /* SELECT PRINTER */
   
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i  "printer" 132}
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:



   {mfphead.i}

   if shift > "" then do:
      FORM /*GUI*/  header
/*N09M     {&reoprp22_p_6} at 61 shift */
/*N09M*/   getTermLabelRtColon("SHIFT",10) format "x(10)" at 61 shift
      with STREAM-IO /*GUI*/  frame shift width 132 no-attr-space page-top.
      view frame shift.
   end.

   for each op_hist where (op_emp >= emp and op_emp <= emp1)
   and (op_date >= opdate and op_date <= opdate1)
   and (op_part >= part and op_part <= part1)
   and (op_wkctr >= wkctr and op_wkctr <= wkctr1)
   and (op_mch >= mach and op_mch <= mach1)
   and (op_type = "LABOR" or op_type = "DOWNTIME")
/*GA37 and (op_act_run <> 0 or op_act_setup <> 0)  */

   and (op_shift = shift or shift = "")
   use-index op_date
   no-lock break by op_wkctr by op_mch by op_date
   by op_part by op_wo_op by op_emp
   with frame b down width 132 no-attr-space:

   /* SET EXTERNAL LABELS */
   setFrameLabels(frame b:handle).

/*K0ZB*/ if c-application-mode <> 'web' then
            view frame phead.

      if first-of(op_mch) then do:
     if page-size - line-counter < 4 then page.
     display WITH STREAM-IO /*GUI*/ .
/*N09M     put {&reoprp22_p_10} op_wkctr {&reoprp22_p_18} op_mch. */
/*N09M* --- ADDED CODE ------------------------------------------ */
     put {gplblfmt.i
     &FUNC=getTermLabel(""WORK_CENTER"",15)
     &CONCAT="': '"
     } op_wkctr " "
     {gplblfmt.i
     &FUNC=getTermLabel(""MACHINE"",14)
     &CONCAT="': '"
     } op_mch.
/*N09M* --------------------------------------------------------- */
     find wc_mstr where wc_wkctr = op_wkctr
     and wc_mch = op_mch no-lock no-error.
     if available wc_mstr then put " " wc_desc.
     if detail then put skip(1).
      end.

      prod_hours = 0.
      down_hours = 0.
      std_hours = 0.
      if op_type = "LABOR" then prod_hours = op_act_setup + op_act_run.
      if op_type = "DOWNTIME" then down_hours = op_act_setup + op_act_run.
      std_hours = prod_hours.
      if op_type = "LABOR" and op_std_run <> 0
/*FU18        then std_hours = op_std_run * op_qty_comp. */
/*FU18*/      then std_hours = op_act_setup + (op_std_run * op_qty_comp).
      accumulate op_qty_comp (total by op_emp).
      accumulate prod_hours (total by op_emp).
      accumulate down_hours (total by op_emp).
      accumulate std_hours (total by op_emp).

      accumulate prod_hours (total by op_mch).
      accumulate down_hours (total by op_mch).
      accumulate std_hours (total by op_mch).

      if last-of(op_emp) then do:
     tot_hours = (accum sub-total by op_emp prod_hours)
     + (accum sub-total by op_emp down_hours).
     pcs_comp = accum sub-total by op_emp op_qty_comp.
     achvd_rate = 0.
     if (accum sub-total by op_emp prod_hours) <> 0 then
     achvd_rate = pcs_comp / (accum sub-total by op_emp prod_hours).
     std_rate = 0.
     if (accum sub-total by op_emp std_hours) <> 0 then
     std_rate = pcs_comp / (accum sub-total by op_emp std_hours).
/*H276*/ /* find ro_det where ro_routing = op_part and ro_op = op_wo_op */
/*H276*/ find last ro_det where ro_routing = op_part and ro_op = op_wo_op
/*H276*/ and (ro_start = ? or ro_start <= opdate) and
/*H276*/ (ro_end = ? or ro_end >= opdate1)
     no-lock no-error.

     /*       if page-size - line-counter < 2 then page. */

/*N09M* ---- ADDED INITIAL VALUES -------------------------- */
        assign
                std_hrs_st      = (accum sub-total by op_emp std_hours)
                down_hrs_st     = (accum sub-total by op_emp down_hours)
                prod_hrs_st     = (accum sub-total by op_emp prod_hours)
                prod_pct_st     = 100 * std_hrs_st / prod_hrs_st
                util_pct_st     = 100 * prod_hrs_st / tot_hours
                attain_pct_st   = 100 * std_hrs_st / tot_hours.
/*N09M* ---------------------------------------------------- */

     if detail then do:
        display op_date op_wo_op WITH STREAM-IO /*GUI*/ .
        if available ro_det then
        display ro_desc format "x(18)" WITH STREAM-IO /*GUI*/ .

        display op_emp
        pcs_comp std_rate achvd_rate

/*N09M  (accum sub-total by op_emp std_hours) label {&reoprp22_p_1}     */
/*N09M*/std_hrs_st label {&reoprp22_p_1}
        format "->,>>9.9"
        tot_hours label {&reoprp22_p_3}
/*N09M  (accum sub-total by op_emp down_hours) label {&reoprp22_p_11}   */
/*N09M*/down_hrs_st label {&reoprp22_p_11}
        format "->,>>9.9"
/*N09M  (accum sub-total by op_emp prod_hours) label {&reoprp22_p_12}   */
/*N09M*/prod_hrs_st label {&reoprp22_p_12}
        format "->,>>9.9"

/*N09M  100 * (accum sub-total by op_emp std_hours)                     */
/*N09M  / (accum sub-total by op_emp prod_hours)                        */
/*N09M*/prod_pct_st
        label {&reoprp22_p_15} format "->>9.9" space(2)

/*N09M  100 * (accum sub-total by op_emp prod_hours) / tot_hours        */
/*N09M*/util_pct_st
        label {&reoprp22_p_8} format "->>9.9"

/*N09M  100 * (accum sub-total by op_emp std_hours) / tot_hours         */
/*N09M*/attain_pct_st
        label {&reoprp22_p_16} format "->>9.9 "
        with frame b STREAM-IO /*GUI*/ .

        down 1.
        display op_part @ ro_desc WITH STREAM-IO /*GUI*/ .
     end.

     accumulate tot_hours (total by op_mch).

      end.

      if last-of(op_mch) then do:
     if page-size - line-counter < 2 then do:
        page.
        clear frame b.
        display WITH STREAM-IO /*GUI*/ .
     end.
/*N09M     if detail then put {&reoprp22_p_9} to 70. */
/*N09M*/   if detail then put wc_mt to 70.

     put (accum sub-total by op_mch std_hours) format "->,>>9.9" to 79
     (accum sub-total by op_mch tot_hours) format "->,>>9.9" to 88
     (accum sub-total by op_mch down_hours) format "->,>>9.9" to 97
     (accum sub-total by op_mch prod_hours) format "->,>>9.9" to 106
     100 * (accum sub-total by op_mch std_hours)
     / (accum sub-total by op_mch prod_hours) format "->>9.9%" to 114
     100 * (accum sub-total by op_mch prod_hours)
     / (accum sub-total by op_mch tot_hours) format "->>9.9%" to 122
     100 * ((accum sub-total by op_mch std_hours)
     *  (accum sub-total by op_mch prod_hours))
     / ((accum sub-total by op_mch prod_hours)
     *  (accum sub-total by op_mch tot_hours))
     format "->>9.9%" to 130.
      end.

      if last (op_mch) then do:
     if page-size - line-counter < 2 then do:
        page.
        clear frame b.
        display WITH STREAM-IO /*GUI*/ .
     end.
/*N09M     put skip(1) {&reoprp22_p_2} to 70 */
/*N09M*/   put skip(1) {gplblfmt.i
               &FUNC=getTermLabel(""REPORT_TOTAL"",16)
               &CONCAT="':'"
               } to 70
     (accum total std_hours) format "->,>>9.9" to 79
     (accum total tot_hours) format "->,>>9.9" to 88
     (accum total down_hours) format "->,>>9.9" to 97
     (accum total prod_hours) format "->,>>9.9" to 106
     100 * (accum total std_hours)
     / (accum total prod_hours) format "->>9.9%" to 114
     100 * (accum total prod_hours)
     / (accum total tot_hours) format "->>9.9%" to 122
     100 * ((accum total std_hours)
     *  (accum total prod_hours))
     / ((accum total prod_hours)
     *  (accum total tot_hours))
     format "->>9.9%" to 130.

      end.

      
/*GUI*/ {mfguirex.i } /*Replace mfrpexit*/

   end.

   /* REPORT TRAILER */
   
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


end.

/*K0ZB*/ {wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" wkctr wkctr1 mach mach1 opdate opdate1 part part1 emp emp1 shift detail "} /*Drive the Report*/
